package com.nlgc365.designpattern.Chapter02_Principle.P01_SRP.CounterExample1;

/**
 * 违反单一职责原则的例子: 包含1个以上的职责, 变化的原因
 * 判断职责是否单一的标准: 变化与变化之间, 是否会发生冲突.
 */
public class Shape {
    private double width;
    private double height;
    private String message = "";

    public Shape(double width, double height) {
        this.width = width;
        this.height = height;
    }

    public Shape(double width, double height, String message) {
        this.width = width;
        this.height = height;
        this.message = message;
    }

    /**
     * 职责1: 计算面积
     *
     * @return
     */
    public double getArea() {
        return width * height;
    }

    /**
     * 职责2: 绘图
     */
    public void draw() {
        System.out.println("Drawing shape with width: " + width + ", height: " + height);
    }
    /*public void draw() {
        System.out.println(message);
    }*/
}
